<!DOCTYPE html>
<#assign f = JspTaglibs["http://www.casic304.cn/f"] />
<#assign dicSelect = JspTaglibs["http://www.casic304.cn/dicSelect"]/>
<#assign SourceDept = JspTaglibs["http://www.casic304.cn/SourceDept"]/>
<head>
    <meta charset="utf-8">
    <title>质量人员信息列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/style/qbdms.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
</head>
<body class="listBody">
<div class="qbdms-list">
    <div class="layui-table-view-body">
    <table id="wQbdTeamPeopleTable" lay-filter="wQbdTeamPeopleTable"></table>
    </div>
</div>
<!-- 列表头部工具栏 -->
<script type="text/html" id="wQbdTeamPeopleHeaderToolsBar">
    <div class="ccpui-enterSel">
        <div class="layui-btn-container">
            <@f.a alias="zltxshyxz,zltxshyxz3" css="layui-btn layui-btn-sm fillBtn" event="add">
                <span>新增</span>
            </@f.a>
            <@f.a alias="zltxshysc,zltxshysc3" css="layui-btn layui-btn-sm" event="delete">
                <span>删除</span>
            </@f.a>

            <@f.a alias="zltxshysb,zltxshysb3" event="report" css="layui-btn layui-btn-sm">
                <span>上报</span>
            </@f.a>
            <a class="layui-btn layui-btn-sm" lay-event="export">
                <span>导出</span>
            </a>
            <@f.a alias="zltxshydr,zltxshydr3" event="import" css="layui-btn layui-btn-sm">
                <span>导入</span>
            </@f.a>
            <a class="layui-btn layui-btn-sm" lay-event="listStyle">
                <span>配置列</span>
            </a>
        </div>
        <form class="layui-form" action="" lay-filter="wQbdTeamPeopleQueryForm" >
            <div class="layui-form-body selch">
                <div class="table-top-filter layui-row">
                    <@SourceDept.dept css="layui-input filter-value "/>
                    <div class="qbdms-listForm">
                            <label class="layui-form-label">姓名</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input filter-value" name="Q_name_SL" placeholder="请输入"/>
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">审核员资格</label>
                        <div class="layui-input-block">
                            <@dicSelect.dic name="Q_qualification_S" css="layui-input filter-value" nodeKey="shyzg" />
                        </div>
<!--                        <input type="text" class="layui-input filter-value" name="Q_qualification_SL" placeholder="请输入"/>-->
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">联系方式</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input filter-value" name="Q_contactinformation_SL" placeholder="请输入"/>
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">性别</label>
                        <div class="layui-input-block">
                            <@dicSelect.dic name="Q_sex_S" css="layui-input filter-value" nodeKey="zjxb" />
                        </div>
<!--                        <input type="text" class="layui-input filter-value" name="Q_sex_SL" placeholder="请输入"/>-->
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">工作单位</label>
                        <div class="layui-input-block">
                            <select class="layui-input filter-value" name="Q_worksid_S" placeholder="请输入" lay-search="">
                                <option value=""></option>
                            </select>
                        </div>
<!--                        <input type="text" class="layui-input filter-value" name="" placeholder=""/>-->
                    </div>
                </div>
                <div class="selchBtn">
                    <a class="layui-btn layui-btn-sm fillBtn" lay-event="query">
                        <span>查询</span>
                    </a>
                    <div class="layui-btn-group">
                        <button type="button" class="layui-btn layui-btn-sm" lay-event="clears" style="width: 28px;font-size: 12px;padding: 0">
                            <i class="iconfont data-iconcommon_refresh"></i>
                        </button>
                        <button type="button" class="layui-btn layui-btn-sm screenParent" lay-event="screen" style="width: 28px;font-size: 12px;padding: 0">
                            <i class="iconfont data-iconcommon_downarrow screen"></i>
                        </button>
                    </div>
                </div>
            </div>
        </form>
    </div>

</script>
<!-- 右侧工具栏 -->
<script type="text/html" id="wQbdTeamPeopleRightToolsBar">
    {{# if('${userId}'==d.createBy && d.allowEdit){}}
        <@f.a alias="zltxshyxg,zltxshyxg3" css="RightBtn" event="edit">编辑</@f.a>
    {{#  } }}
    <a class="RightBtn" lay-event="particulars">详情</a>
    {{# if((d.reportStatus==4||d.reportStatus==12) && '${userId}'==d.createBy){ }}
        <@f.a alias="zltxshysc,zltxshysc3" css="RightBtn" event="del">删除</@f.a>
    {{#  } }}
</script>
<script src="${ctx}/qbdmsStatic/public/configFile.js"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>
    //一般直接写在一个js文件中
    layui.config({
        base: serverPath.qbdmsPath + staticPath.qbdmsPath //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'form', 'common', 'publicMethods', 'jquery', 'layer'], function () {
        var table = layui.table;
        var form = layui.form;
        var common = layui.common;
        var publicMethods = layui.publicMethods;
        var $ = layui.jquery;
        var layer = layui.layer;
        common.tableSort('wQbdTeamPeopleTable');

        var tableH=publicMethods.tabHeight();

        var cols = '${cols}';

        var currentSystemLevel = "${currentSystemLevel}";
        var snCols = [{type: 'checkbox', fixed: 'left'},{field: 'sn', type: 'numbers', title: '序号', fixed: 'left', minWidth: 90}];
        var fillDeptCols = [];
        if ("GROUPLEVEL" === currentSystemLevel) {
            fillDeptCols = [{field: 'filldeptHospital', title: '数据来源单位', sort: false, minWidth: 140, sortname: 'filldepthospital'}];
        } else if ("HOSPITALLEVEL" === currentSystemLevel) {
            fillDeptCols = [{field: 'filldept', title: '数据来源单位', sort: false, minWidth: 140, sortname: 'filldept'}];
        } else if ("PLANTLEVEL" === currentSystemLevel) {
            fillDeptCols = [{field: 'filldept', title: '数据来源单位', sort: false, minWidth: 140, sortname: 'filldept'}];
        }
        var commonCols = [
            {field: 'name', title: '姓名',sort:false, minWidth: 140, sortname: 'name'}
            ,{field: 'sex', title: '性别',sort:false,width:70, minWidth: 60, sortname: 'sex'}
            ,{field: 'works', title: '工作单位', minWidth: 160,sort:false, sortname: 'works'}
            ,{field: 'qualification', title: '审核员资格',sort:false, minWidth: 140, sortname: 'qualification'}
            ,{field: 'contactinformation', title: '联系方式',sort:false, minWidth: 140, sortname: 'contactinformation'}
            ,{field: 'address', title: '地址',sort:false, minWidth: 140, sortname: 'address'}

            ,{field: 'jiguan', title: '籍贯',sort:false, minWidth: 140, sortname: 'jiguan',hide:true}
            ,{field: 'minzu', title: '民族',sort:false, minWidth: 140, sortname: 'minzu',hide:true}
            //如需转换为:yyyy-MM-dd HH:mm:ss: return publicMethods.timeData(d.birthday,"1");
            //如需转换为HH:mm:ss: return publicMethods.timeData(d.birthday,"2");
            // 当前转换后的格式为yyyy-MM-dd: return publicMethods.timeData(d.birthday);
            ,{field: 'birthday', title: '出生日期',sort:false,hide:true, minWidth: 140, sortname: 'birthday',templet: function (d) {
                    return publicMethods.timeData(d.birthday);
                }}
            ,{field: 'peopletype', title: '人员类别',sort:false, minWidth: 140, sortname: 'peopletype',hide:true}
            ,{field: 'remark', title: '备注',sort:false, minWidth: 140, sortname: 'remark',hide:true}
            ,{field: 'phone', title: '座机',sort:false, minWidth: 140, sortname: 'phone',hide:true}
            ,{field: 'idcode', title: '证件号码',sort:false, minWidth: 140, sortname: 'idcode',hide:true}
            //如需转换为:yyyy-MM-dd HH:mm:ss: return publicMethods.timeData(d.createTime,"1");
            //如需转换为HH:mm:ss: return publicMethods.timeData(d.createTime,"2");
            // 当前转换后的格式为yyyy-MM-dd: return publicMethods.timeData(d.createTime);
            // ,{field: 'createTime', title: 'createTime',sort:true,hide:true, sortname: 'createtime',templet: function (d) {
            //         return publicMethods.timeData(d.createTime);
            //     }}
            // ,{field: 'updateBy', title: 'updateBy',sort:true, sortname: 'updateby',hide:true}
            //如需转换为:yyyy-MM-dd HH:mm:ss: return publicMethods.timeData(d.updateTime,"1");
            //如需转换为HH:mm:ss: return publicMethods.timeData(d.updateTime,"2");
            // 当前转换后的格式为yyyy-MM-dd: return publicMethods.timeData(d.updateTime);
            // ,{field: 'updateTime', title: 'updateTime',hide:true,sort:true, sortname: 'updatetime',templet: function (d) {
            //         return publicMethods.timeData(d.updateTime);
            //     }}
            // ,{field: 'reportStatus', title: 'reportStatus',sort:true, sortname: 'report_status',hide:true}
            // ,{field: 'reportReason', title: 'reportReason',sort:true, sortname: 'report_reason',hide:true}
            // ,{field: 'reportStatusTemp', title: 'reportStatusTemp',sort:true, sortname: 'report_status_temp',hide:true}
            // ,{field: 'returnmsg', title: 'returnmsg',sort:true, sortname: 'returnmsg',hide:true}
            //如需转换为:yyyy-MM-dd HH:mm:ss: return publicMethods.timeData(d.reportDate,"1");
            //如需转换为HH:mm:ss: return publicMethods.timeData(d.reportDate,"2");
            // 当前转换后的格式为yyyy-MM-dd: return publicMethods.timeData(d.reportDate);
            // ,{field: 'reportDate', title: 'reportDate',sort:true,hide:true, sortname: 'report_date',templet: function (d) {
            //         return publicMethods.timeData(d.reportDate);
            //     }}
        ];

        var reportStatusCols =[];
        if ("GROUPLEVEL" !== currentSystemLevel) {
            reportStatusCols = [{
                field: 'reportStatusStr', title: '状态', sort: false, sortname: 'REPORT_STATUS', minWidth: 200, hide: false, templet: function (d) {
                    if (d.reportStatus == 18 || d.reportStatus == 10) {
                        return returnComments(d);
                    } else {
                        return common.stateType(d);
                    }

                }
            }];
        }

        function returnComments(d) {
            return "<a style=\"cursor: pointer;color:red\" onclick=\"layer.open({title: '退回意见',content: '" + d.returnmsg + "'});\">" + d.reportStatusStr + "</a>";
        }

        var manageCols = [{
            fixed: 'right',
            title: '管理',
            toolbar: '#wQbdTeamPeopleRightToolsBar',
            minWidth: 180
        }];
        var totalCols = snCols.concat(fillDeptCols).concat(commonCols).concat(reportStatusCols).concat(manageCols);




        window.tableInstace = function(tcols) {
            if (tcols) {
                cols = tcols;
            }
            if (cols) {
                cols = JSON.parse(cols, function (k, v) {
                    if (v.indexOf && v.indexOf('function') > -1) {
                        return eval("(function(){return " + v + " })()")
                    }
                    return v;
                })
            }
            window.tableInstace.initCols = totalCols;
            //第一个实例
            window.tableInstace.tRender = table.render({
                elem: '#wQbdTeamPeopleTable'
                ,height:tableH
                ,url: serverPath.qbdmsPath + '/qbdms/wQbdTeamPeople/list'
                ,toolbar: '#wQbdTeamPeopleHeaderToolsBar'
                ,limit: 20
                ,defaultToolbar: ['']
                ,page: publicMethods.pageFun()
                ,method: 'post'
                ,autoSort: false //是否排序
                ,cols: [cols?cols:window.tableInstace.initCols],done:function () {
                    common.tableSelectCon('.ccpui-enterSel .layui-form input','a[lay-event=query]','.ccpui-enterSel');
                }
                ,parseData: function(res){ //res 即为原始返回的数据
                    common.parseDataList(res,['address','filldeptHospital']);
                    return {
                        "code": res.code, //解析接口状态
                        "msg": res.msg, //解析提示文本
                        "count": res.count, //解析数据长度
                        "data": res.data //解析数据列表
                    };
                }
            });

        }
        window.tableInstace(cols);

        //list页面初始化展开按钮tips展示（展开按钮类名）
        publicMethods.tipsAuto('.screen')
        //筛选条件初始化（页面表格的Id，是否初始化（true、false））
        common.initScreenTop('wQbdTeamPeopleTable',true);
        //监听排序事件
        table.on('sort()', function () {
            reflashQuery(false);
            dateReflash();
        });


        dateReflash()
        function dateReflash() {
            // publicMethods.reflashDate({startName:'.start_time1',endName:'.end_time1'});
            // publicMethods.reflashDate({startName:'.start_time2',endName:'.end_time2'});
            // publicMethods.reflashDate({startName:'.start_time3',endName:'.end_time3'});
            // publicMethods.reflashDate({startName:'.start_time4',endName:'.end_time4'});
        }

        function reflashQuery(isClear) {
            common.tableConditionRender("wQbdTeamPeopleTable","wQbdTeamPeopleQueryForm",{where:{}},isClear, false, 20);
            setOrg();
        }

        table.on('toolbar(wQbdTeamPeopleTable)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            var data = checkStatus.data;
            var _this = this;
            var layerH=publicMethods.layHeight('.listBody');
            switch (obj.event) {
                case 'add':
                    window.location.href = serverPath.qbdmsPath + "/qbdms/wQbdTeamPeople/view/add";
                    break;
                case 'delete':
                    var array = "";
                    for (var i = 0; i < data.length; i++) {
                        array+=data[i].id+",";
                    }
                    delFun(data,array);
                    break;
                case 'export':
                    function open(url , param){
                        var curUrl = url;
                        layer.open({
                            type: 2,
                            area: ['700px', '520px'],
                            title: ['自定义导出', 'font-size:14px;'],
                            content: serverPath.qbdmsPath + '/qbdms/wQbdTeamPeople/view/export',
                            btnAlign: 'c',
                            skin: 'qbdms-layerFormBtn',
                            btn: ['确定', '取消'],
                            yes: function(index, layero){
                                url = curUrl;
                                var iframeWin = window["layui-layer-iframe" + index];
                                var data = iframeWin.getData();
                                if(data){
                                    url = url + "?data=" + JSON.stringify(data) + param;
                                    window.location.href = encodeURI(url)
                                }
                            }
                        });
                    }


                    if (data.length == 0) {
                        layer.confirm(publicMethods.confirmStyle('还没有选择，是否导出全部？'),{title: false,skin: 'confirm-class'}, function (index) {
                            layer.close(index);
                            var url = serverPath.qbdmsPath + '/qbdms/wQbdTeamPeople/exportData';
                            var param = "";
                            $("form[lay-filter='wQbdTeamPeopleQueryForm']").find(".filter-value").each(function(i,value) {
                                param += "&"+this.name+"="+this.value
                            });
                            open(url , param);
                        });
                    } else {
                        layer.confirm(publicMethods.confirmStyle('确定导出吗？'),{title: false,skin: 'confirm-class'}, function (index) {
                            layer.close(index);
                            var ids = [];
                            for (var i = 0; i < data.length; i++) {
                                ids.push(data[i].id);
                            }
                            var url = __ctx + '/qbdms/wQbdTeamPeople/exportData';
                            open(url , "&id="+ids);
                        });
                    }
                    break;
                case "import":
                    common.importInit('wQbdTeamPeopleTable',"/qbdms/wQbdTeamPeople/importData",true,"/importTemplates/质量体系审核员.xlsx");
                    dateReflash();
                    break;
                case "query":
                    reflashQuery(false);
                    dateReflash();
                    break;
                case "screen":
                    common.initScreenTop('wQbdTeamPeopleTable');
                    dateReflash();
                    form.render();
                    break;
                case "clears":
                    reflashQuery(true);
                    dateReflash();
                    break;
                case "report":
                    var ids = "";
                    for (var i = 0; i < data.length; i++) {
                        ids += data[i].id + ",";
                    }

                    //业务表名,勾选数据主键,流程key,table标签lay-filter属性值,form标签lay-filter属性值,是否允许重复上报,页面所在包名,流程定义id
                    common.report("W_QBD_TEAM_PEOPLE", ids, "plantToHospital", "wQbdTeamPeopleTable", "wQbdTeamPeopleQueryForm", false, "wQbdTeamPeople", "plantToHospital:1:72d05d40362249118c5453aa60c6da90");
                    dateReflash();
                    break;
                case "listStyle":
                    layer.open({
                        type: 2,
                        area: ['80%', layerH],
                        skin: 'qbdms-layerFormBtn',
                        title: ['新增列表样式', 'font-size:14px;'],
                        content: __ctx + '/qbdms/wCustomColumns/view/list',
                        success:function (layero, index) {
                            publicMethods.tipsAuto(layero.find('.layui-layer-setwin'),'点击这里关闭弹框哦',2000)
                        }
                    });
                    break;

            };
        });

        table.on('tool(wQbdTeamPeopleTable)', function(obj) {
            var data = obj.data, //获得当前行数据
                    layEvent = obj.event; //获得 lay-event 对应的值
            switch(layEvent){
                case "edit":

                    window.location.href = serverPath.qbdmsPath + '/qbdms/wQbdTeamPeople/view/add?id='+data.id;
                    break;
                case "particulars":

                    window.location.href = serverPath.qbdmsPath + '/qbdms/wQbdTeamPeople/view/particulars?id='+data.id;
                    break;
                case "del":
                    delFun(data,data.id);
                    break;
            }
        });

        function delFun(data,id) {
            if (data.length === 0) {
                layer.alert(publicMethods.confirmStyle('请先选择一行数据!'),{title: false,skin: 'confirm-class'});
            } else {
                layer.confirm(publicMethods.confirmStyle('确定删除当前数据吗?'),{title: false,skin: 'confirm-class'}, function (index) {
                    layer.close(index);
                    $.ajax({
                        url: serverPath.qbdmsPath + "/qbdms/wQbdTeamPeople/del",
                        type: "post",
                        data: {id:id},
                        dataType: 'json',
                        success: function (data) {
                            layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        }
                    })
                })
            }
        }


        function setOrg() {
            var org = eval('${org}');
            var orgHtml = "<option value=\"\"></option>";
            $.each(org, function (index, obj) {
                orgHtml += "  <option  orgid='" + obj.CODE + "' value='" + obj.CODE + "'  >" + obj.ORGNAME + "</option>";
            });
            $("select[name='Q_worksid_S']").html(orgHtml);
        }

        setOrg();

        window.Initialization = function () {
            dateReflash();
            reflashQuery(true);
        };
        /*刷新时间控件*/
        dateReflash();
        common.tableSort("wQbdTeamPeopleTable",{show:window.Initialization});
    });
</script>
</body>
</html>